using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BuddhistSchools.DTO.Models.Mapping
{
    public class ScoreMap : EntityTypeConfiguration<Score>
    {
        public ScoreMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("Score");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Term_SubjectID).HasColumnName("Term_SubjectID");
            this.Property(t => t.StudentID).HasColumnName("StudentID");
            this.Property(t => t.ScoreColumnID).HasColumnName("ScoreColumnID");
            this.Property(t => t.Score1).HasColumnName("Score");
            this.Property(t => t.UserID).HasColumnName("UserID");

            // Relationships
            this.HasRequired(t => t.ScoreColumn)
                .WithMany(t => t.Scores)
                .HasForeignKey(d => d.ScoreColumnID);
            this.HasRequired(t => t.Student)
                .WithMany(t => t.Scores)
                .HasForeignKey(d => d.StudentID);
            this.HasRequired(t => t.Term_Subject)
                .WithMany(t => t.Scores)
                .HasForeignKey(d => d.Term_SubjectID);
            this.HasRequired(t => t.User)
                .WithMany(t => t.Scores)
                .HasForeignKey(d => d.UserID);

        }
    }
}
